using UnityEngine;
using UnityEngine.UI;

namespace MaterialUI
{
	[AddComponentMenu("MaterialUI/Dialogs/Progress", 1)]
	public class DialogProgress : MaterialDialog
	{
		[SerializeField]
		private DialogTitleSection m_TitleSection = new DialogTitleSection();

		[SerializeField]
		private Text m_BodyText;

		private ProgressIndicator m_ProgressIndicator;

		[SerializeField]
		private ProgressIndicator m_LinearIndicator;

		[SerializeField]
		private ProgressIndicator m_CircularIndicator;

		public DialogTitleSection titleSection
		{
			get
			{
				return m_TitleSection;
			}
			set
			{
				m_TitleSection = value;
			}
		}

		public Text bodyText => m_BodyText;

		public ProgressIndicator progressIndicator
		{
			get
			{
				return m_ProgressIndicator;
			}
			set
			{
				m_ProgressIndicator = value;
			}
		}

		public void Initialize(string bodyText, string titleText, ImageData icon, bool startStationaryAtZero = true)
		{
			m_TitleSection.SetTitle(titleText, icon);
			if (string.IsNullOrEmpty(bodyText))
			{
				m_BodyText.transform.parent.gameObject.SetActive(value: false);
			}
			else
			{
				m_BodyText.text = bodyText;
			}
			if (!startStationaryAtZero)
			{
				m_ProgressIndicator.StartIndeterminate();
			}
			else
			{
				m_ProgressIndicator.SetProgress(0f, animated: false);
			}
			Initialize();
		}

		public void SetupIndicator(bool isLinear)
		{
			m_LinearIndicator.gameObject.SetActive(isLinear);
			m_CircularIndicator.gameObject.SetActive(!isLinear);
			m_ProgressIndicator = ((!isLinear) ? m_CircularIndicator : m_LinearIndicator);
			m_ProgressIndicator.transform.parent.GetComponent<VerticalLayoutGroup>().childForceExpandWidth = isLinear;
		}
	}
}
